﻿using MediatR;
using ProductIntory.Domains;
using Purchase.ApiS.ListDisplay.Command;
using Purchase.Domian.Model;
using Purchase.ErrorCode;
using Purchase.Infrastructrue.Implenment;

namespace Purchase.ApiS.ListDisplay.Hanlder
{
    public class GetUserCommandHanlder : IRequestHandler<GetUserCommand, ApiResult<QualityInspectionModel>>
    {
        public readonly IBaseRepostity<QualityInspectionModel> _userRepostity;
        public readonly ILogger<GetUserCommandHanlder> _logger;

        public GetUserCommandHanlder(IBaseRepostity<QualityInspectionModel> userRepostity, ILogger<GetUserCommandHanlder> logger)
        {
            _userRepostity = userRepostity;
            _logger = logger;
        }
        /// <summary>
        /// 质检人员的列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>

        public Task<ApiResult<QualityInspectionModel>> Handle(GetUserCommand request, CancellationToken cancellationToken)
        {
            ApiResult<QualityInspectionModel> result = new ApiResult<QualityInspectionModel>();
            try
            {
                var user = _userRepostity.GetAll().ToList();
                result.Code = ApiEume.Success;
                result.Msg = "获取质检人员的列表成功";
                result.Datas = user;

            }
            catch (Exception ex)
            {

            }
            return Task.FromResult(result);
        }
    }
}
